package cn.elegent.tx.core.manager;

import cn.elegent.tx.core.manager.task.LoopJob;
import cn.elegent.tx.core.entity.TransactionEntity;
import cn.elegent.tx.core.entity.state.TransactionState;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * TransactionManagerImpl
 * @description 事务管理器
 * @author WGL
 * @date 2022/11/7 14:21
*/
@Component
@Slf4j
public class TransactionManagerImpl implements TransactionManager{

    public static final String ROLLBACK_TOPIC = "elegent-rollback/";


    @Autowired
    private LoopJob loopJob;


    /**
     * 发送回滚消息的方法
     * @param transactionEntity
     */
    @Override
    public void sendRollBackMsg(TransactionEntity transactionEntity) {
        log.info("----------使用定时任务发送回滚消息------------2");
        //使用定时任务发送回滚消息
        loopJob.sendRollBackMsg(transactionEntity, TransactionState.SUCCESS);
    }
}
